using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace RiceShop.Models
{
    /// <summary>
    /// 商品评论实体类
    /// </summary>
    [Table("Comments")]
    public class Comments
    {
        /// <summary>
        /// 评论ID
        /// </summary>
        [Key]
        public long Id { get; set; }

        /// <summary>
        /// 用户ID
        /// </summary>
        public long UserId { get; set; }

        /// <summary>
        /// 订单编号
        /// </summary>
        [Required]
        [StringLength(32)]
        public string OrderNo { get; set; } = string.Empty;

        /// <summary>
        /// 商品SPU ID
        /// </summary>
        public long SpuId { get; set; }

        /// <summary>
        /// SKU ID
        /// </summary>
        public long SkuId { get; set; }

        /// <summary>
        /// 评分(1-5)
        /// </summary>
        public byte Score { get; set; }

        /// <summary>
        /// 评论内容
        /// </summary>
        [Required]
        [StringLength(500)]
        public string Content { get; set; } = string.Empty;

        /// <summary>
        /// 图片列表（JSON格式）
        /// </summary>
        public string? Images { get; set; }

        /// <summary>
        /// 是否匿名
        /// </summary>
        public bool IsAnonymous { get; set; }

        /// <summary>
        /// 是否删除
        /// </summary>
        public bool IsDeleted { get; set; }

        /// <summary>
        /// 关联的用户
        /// </summary>
        [ForeignKey("UserId")]
        public virtual User User { get; set; } = null!;

        /// <summary>
        /// 关联的商品
        /// </summary>
        [ForeignKey("SpuId")]
        public virtual Good Good { get; set; } = null!;

        /// <summary>
        /// 关联的订单
        /// </summary>
        [ForeignKey("OrderNo")]
        public virtual Order Order { get; set; } = null!;
    }
}